<div id ="shop" style="width:950px;">
	<div style="clear: both; height:23px; background-color: #F6F9FF; border: 1px solid; border-color: #DDDDDD ">
	   	<div  style="float: left;padding:4px; font-size:16px; text-transform:uppercase; color:#AA5FFF">
			Danh sách sản phẩm của bạn
		</div>
        <div style="float:right; font-size:14px; font-weight:bold; text-transform:uppercase; color:#FFFBF0; padding-top:2px; height:20px;">
          <span style=" background:#FF5F00"><a style=" text-decoration:none; color:#FFFBF0" href="index.php?route=upload/upload">Đăng tin mới</a> </span> <span>&nbsp;&nbsp;</span>
         <span style=" background:#FF5F00"><a style=" text-decoration:none; color:#FFFBF0" onClick="deleteProduct();">xóa</a></span> 
        
        </div>
	</div>
  <div style="margin-top: 4px;">
  	<div id="review_title"></div>
 
  <?php if (isset($products)) { ?>
  	<div class="pagination" style="margin-top:4px; ">
	<?php echo $pagination; ?>
    </div>
       	
  		<table class="catalog" style="float: left; border-collapse: collapse">
  			<tr style="background-color: #DDFDDF; font-weight:bold; color:#2A1FFF; text-transform:uppercase; font-size:14px;">
                <td style="text-align: center;" width="3%"></td>
                <td style="text-align: center;" width="15%">Ảnh</td>
                <td style="text-align: center;" width="40%">Tên sản phẩm</td>
                <td style="text-align: center;" width="15%">Giá</td>
                <td style="text-align: center;" width="15%">Phạm vi bán</td>
                <td style="text-align: center;" width="5%">Sửa</td>
            </tr><!--End first row-->
            <tr>
                <td>
                <input type="checkbox" id="checkbox_setall" name="loc_all_pro" onChange="selectAll_Product();" />
                </td>
                <td style="text-align: center;" ></td>
                <td style="text-align: center;" ></td>
                <td style="text-align: center;" >
                	<select name="sort" onchange="getCatalogData(this.value);" style="width:110px; padding-left: 4px;">
						<?php foreach ($sorts as $sorts) { ?>
							<?php if (($sort . '-' . $order) == $sorts['value']) { ?>
                            	<option value="<?php echo $sorts['href']; ?>" selected="selected"><?php echo $sorts['text']; ?></option>
                            <?php } 
                            else { ?>
                                 <option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
                            <?php } ?>
                            <?php } ?>
                     </select>
                </td>
                <td style="text-align: center;" >
                		<select name="zone_id" id="zone_id" onchange="getCatalogData(this.value);">
							  <?php foreach ($areas as $area) { ?>
                                    <?php if(isset($this->request->get['shop'])) { ?>
                                        <option value="<?php 
										echo $this->url->http('shops/shop/ajax&shop=' .
											 $this->request->get['shop'] . '&zone_id='.
											 $area['zone_id']); ?>" <?php if( $zone_id == $area['zone_id']) echo "selected";?> >
                                              <?php echo $area['name']; ?></option>
                                     <?php } else { ?>
                                        <option value="<?php echo $this->url->http('shops/shop/ajax&zone_id='.
										$area['zone_id']); ?>" <?php if( $zone_id == $area['zone_id']) 
										echo "selected";?> > <?php echo $area['name']; ?></option>
                                     <?php } ?>
                              <?php } ?>
                       </select>
                </td>
                <td>
                
                </td>
            </tr>
     <form name="product_delete" method="post" action="">       
  	<?php for ($i = 0; $i < sizeof($products); $i++) { ?>
  	<tr>
    	<td style="text-align: center;" >
            <input type="checkbox" name="checkbox_product<?php echo $i;?>" id="<?php echo $i?>"/>
            <input type="hidden" name="hidden_product<?php echo $i;?>" value="<?php echo $products[$i]['product_id'];?>"/>
        </td>
  		<td >
  			<a href="<?php echo $products[$i]['href']; ?>">
  				<img style="margin-left:2px; margin-top:2px;" src="<?php echo $products[$i]['thumb']; ?>" width="120"/>
  			</a>
  		</td>
  		<td >
  			<div style="margin-top:2px; margin-left:2px; text-transform:uppercase;font-size:12px;">
            <a style=" text-decoration:none; color:#00F; font-size:16px" href="<?php echo $products[$i]['href']; ?>"><?php echo $products[$i]['name']; ?></a>
            </div>
            <div style="margin-top:10px;">
            	<div style="font-weight:bold; border-bottom:solid 1px #FF5F55; width:300px; size:14px;">
                Thông tin chi tiết:
                </div>
                <div>
                  <div style="color: #999; font-size: 13px;">
                      Ngày Đăng:<?php echo $products[$i]['date_added']; ?> 
                  </div>
                  <div style="color: #999; font-size: 13px;">
                      Xem:<?php echo $products[$i]['viewed']; ?> 
                  </div>
                  <div style="color: #999; font-size: 13px;">
                      Comments:<?php echo $products[$i]['rating']; ?>
                  </div>
                </div>
            
            </div>
  			
  		</td>
  		<td>
	  		<?php if ($display_price) { ?>
	        		<?php if (!$products[$i]['special']) { ?>
	        			<span style="color: #900; font-weight: bold;"><?php echo $products[$i]['price']; ?>
	        			</span>
	        		<?php } else { ?>
	        			<span style="color: #900; font-weight: bold; text-decoration: line-through;">
	        			<?php echo $products[$i]['price']; ?>
	        			</span>
                       
	        			<span style="color: #F00;">
	        				<?php echo $products[$i]['special']; ?>
	        			</span>
	        	<?php } ?>
	        <?php } ?>
  		</td>
  		<td align="center">
  			<span style="font-size: 14px; text-transform:uppercase; font-weight:bold;">
  				<?php echo $products[$i]['zone']; ?>
  			</span>
  		</td>
        <td>
        <a onclick="edit(<?php echo $products[$i]['product_id'];?>);">Sửa</a>
        </td>
  	</tr>
  <?php }
  $max_value_product=sizeof($products); 
  ?>
  <input type="hidden" name="max_value_product" value="<?php echo sizeof($products);  ?>">
   </form>
  </table>
 
  	</div>
  	<div class="pagination" style="margin-top:4px; "><?php echo $pagination; ?></div>
  <?php } else { ?>
  	<table class="catalog" style="float: left; border-collapse: collapse">
  			<tr style="background-color: #DDFDDF; font-weight:bold; color:#2A1FFF; text-transform:uppercase; font-size:14px;">
                <td style="text-align: center;" width="3%"></td>
                <td style="text-align: center;" width="15%">Ảnh</td>
                <td style="text-align: center;" width="40%">Tên sản phẩm</td>
                <td style="text-align: center;" width="15%">Giá</td>
                <td style="text-align: center;" width="15%">Phạm vi bán</td>
                <td style="text-align: center;" width="5%">Sửa</td>
            </tr><!--End first row-->
            <tr>
                <td>
                <input type="checkbox" id="checkbox_setall" name="loc_all_pro" onChange="selectAll_Product();" />
                </td>
                <td style="text-align: center;" ></td>
                <td style="text-align: center;" ></td>
                <td style="text-align: center;" >
                	<select name="sort" onchange="getCatalogData(this.value);" style="width:110px; padding-left: 4px;">
						<?php foreach ($sorts as $sorts) { ?>
							<?php if (($sort . '-' . $order) == $sorts['value']) { ?>
                            	<option value="<?php echo $sorts['href']; ?>" selected="selected"><?php echo $sorts['text']; ?></option>
                            <?php } 
                            else { ?>
                                 <option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
                            <?php } ?>
                            <?php } ?>
                     </select>
                </td>
                <td style="text-align: center;" >
                		<select name="zone_id" id="zone_id" onchange="getCatalogData(this.value);">
							  <?php foreach ($areas as $area) { ?>
                                    <?php if(isset($this->request->get['shop'])) { ?>
                                        <option value="<?php 
										echo $this->url->http('shops/shop/ajax&shop=' .
											 $this->request->get['shop'] . '&zone_id='.
											 $area['zone_id']); ?>" <?php if( $zone_id == $area['zone_id']) echo "selected";?> >
                                              <?php echo $area['name']; ?></option>
                                     <?php } else { ?>
                                        <option value="<?php echo $this->url->http('shops/shop/ajax&zone_id='.
										$area['zone_id']); ?>" <?php if( $zone_id == $area['zone_id']) 
										echo "selected";?> > <?php echo $area['name']; ?></option>
                                     <?php } ?>
                              <?php } ?>
                       </select>
                </td>
                <td>
                
                </td>
            </tr>
             <tr>
                    <td colspan="6">
                        Không có sản phẩm nào được tìm thấy trong khu vực này!
                    </td>
             </tr>
	</table>
	<?php }  ?>
	<br></br>
</div>
<div class="bottom">
<form name="edit_product" action="" method="post">
<input name="product_id" value="" type="hidden" />
</form>
&nbsp;</div>
<style type="text/css">
	.catalog tr {
		border-bottom:1px solid #DDDFFF;
		border-left: 1px solid #DDDDDD;
	}
	.catalog tr td {
		border:1px solid #DDDFFF;
		text-align: left;
		margin-top: 2px;
		padding-left: 10px;
	}

</style>
<script type="text/javascript">
function getCatalogData(shop) {
	$.ajax({
		type: 'post',
		url:shop,
		dataType: 'json',
		beforeSend: function() {
			$('#review_title').after('<div style="width:950px; text-align: center;" class="wait">Hệ thống đang xử lý...<img src="catalog/view/theme/default/image/loading_1.gif" alt="" /></div>');
		},
		complete: function() {
			//alert(shop);
		},
		success: function(data) {
			//alert(data.html);
			if (data.error) {
				$('#review_title').after('<div class="warning">' + data.error + '</div>');
			}
			if (data.success) {
				//$("#content").html("");
				$("#content_shops").html(data.html);
			}
		}
	});
}
function edit(id){
	var frm = document.edit_product;
	var frm_id = document.getElementsByName('product_id')[0];
	var flag = true;
	if (flag){
		flag = false;
		frm_id.value=id;
		frm.action ="<?php echo $href_modify; ?>"+id;
		frm.submit();
	}
}
function selectAll_Product()
{	
	st='checkbox_product';
	max_value_product=<?php echo $max_value_product; ?>;
	i=0;
    
	for(i=0;i<max_value_product;i++){
    	document.getElementsByName(st+i).item(0).checked=document.getElementsByName('loc_all_pro').item(0).checked;
	}
	
};
function deleteProduct(){
	answer = confirm("Bạn có muốn xóa các sản phẩm này khỏi gian hàng?")
	frm = document.product_delete;
	if (answer){
    	frm.action="?route=upload/product/delete_listproduct";
    	frm.submit();
	}
}
</script>